package com.csust.travel.task;


import com.csust.travel.mapper.BooksMapper;
import com.csust.travel.util.CloudUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.List;

@EnableScheduling
@Component
public class CleanTask {

    @Autowired
    BooksMapper booksMapper;

    @Scheduled(cron = "0 0 4 * * *")
    public void test(){
        List<String> db = booksMapper.findDb();

        List<String> cloud = CloudUtil.findFile();

        cloud.removeAll(db);

        if(!cloud.isEmpty()){
            CloudUtil.deleteFile(cloud);
        }

    }

}
